package com.joker.demo.controller;


import com.joker.demo.service.ChatMemoryAssistant;
import dev.langchain4j.service.UserMessage;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 聊天内存控制
 *
 * @author : feixiang.li
 * @since : 2025-09-25 17:35
 */
@RestController
@RequestMapping("/chatMemory")
public class ChatMemoryController {

    @Resource(name = "chatMemoryWithMaxMessage")
    private ChatMemoryAssistant chatMemoryWithMaxMessage;

    @Resource(name = "chatTokenWindowChatMemory")
    private ChatMemoryAssistant chatTokenWindowChatMemory;


    @RequestMapping("/chatMemoryWithMaxMessage")
    public String chat(@RequestParam(value = "question", defaultValue = "你是谁") String question,
                       @RequestParam(value = "memberId", defaultValue = "0") Long memberId) {
        return chatMemoryWithMaxMessage.chat(memberId, question);
    }

    @RequestMapping("/chatTokenWindowChatMemory")
    public String chatTokenWindowChatMemory(@RequestParam(value = "question", defaultValue = "你是谁") String question,
                                            @RequestParam(value = "memberId", defaultValue = "0") Long memberId) {
        return chatTokenWindowChatMemory.chat(memberId, question);
    }
}
